package com.liming.stock.controller;

import com.liming.common.pojo.dto.stock.warehouse.WarehouseAddDTO;
import com.liming.common.pojo.dto.stock.warehouse.WarehousePageQuery;
import com.liming.common.pojo.dto.stock.warehouse.WarehouseUpdateDTO;
import com.liming.common.pojo.vo.PageVO;
import com.liming.common.pojo.vo.stock.warehouse.WarehouseVO;
import com.liming.common.result.LMResult;
import com.liming.stock.service.WarehouseMircoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author liming
 * @date 2025/3/1
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "仓库接口-Service")
@RequestMapping("/service/warehouse")
public class WarehouseMircoController {

    private final WarehouseMircoService warehouseMircoService;

    @GetMapping
    public LMResult<PageVO<WarehouseVO>> page(WarehousePageQuery query) {
        return LMResult.success(warehouseMircoService.pageByQuery(query));
    }

    @PostMapping
    public LMResult<Boolean> add(@RequestBody WarehouseAddDTO warehouseAddDTO) {
        return LMResult.success(warehouseMircoService.add(warehouseAddDTO));
    }

    @PutMapping
    public LMResult<Boolean> update(@RequestBody WarehouseUpdateDTO warehouseUpdDTO) {
        return LMResult.success(warehouseMircoService.editById(warehouseUpdDTO));
    }

    @DeleteMapping("{id}")
    public LMResult<Boolean> delete(@PathVariable Long id) {
        return LMResult.success(warehouseMircoService.removeById(id));
    }
}
